var e = require("../@babel/runtime/helpers/interopRequireDefault"), t = e(require("./showdown.js")), a = e(require("./html2json.js")), i = 0, r = 0;

function n(e) {
    var t = e.target.dataset.src, a = e.target.dataset.from;
    void 0 !== a && a.length > 0 && wx.previewImage({
        current: t,
        urls: this.data[a].imageUrls
    });
}

function o(e) {
    var t = e.target.dataset.from, a = e.target.dataset.idx;
    void 0 !== t && t.length > 0 && function(e, t, a, n) {
        var o = a.data[n];
        if (!o || 0 == o.images.length) return;
        var d = o.images, s = function(e, t, a, n) {
            var o = 0, d = 0, s = 0, l = {}, g = a.data[n].view.imagePadding;
            r, e > (o = i - 2 * g) ? (s = (d = o) * t / e, l.imageWidth = d, l.imageheight = s) : (l.imageWidth = e, 
            l.imageheight = t);
            return l;
        }(e.detail.width, e.detail.height, a, n), l = d[t].index, g = "".concat(n), h = !0, v = !1, m = void 0;
        try {
            for (var u, f = l.split(".")[Symbol.iterator](); !(h = (u = f.next()).done); h = !0) {
                var w = u.value;
                g += ".nodes[".concat(w, "]");
            }
        } catch (e) {
            v = !0, m = e;
        } finally {
            try {
                h || null == f.return || f.return();
            } finally {
                if (v) throw m;
            }
        }
        var c = g + ".width", x = g + ".height";
        a.setData({
            [c]: s.imageWidth,
            [x]: s.imageheight
        });
    }(e, a, this, t);
}

wx.getSystemInfo({
    success: function(e) {
        i = e.windowWidth, r = e.windowHeight;
    }
}), module.exports = {
    wxParse: function() {
        var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "wxParseData", i = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "html", r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : '<div class="color:red;">数据不能为空</div>', d = arguments.length > 3 ? arguments[3] : void 0, s = arguments.length > 4 ? arguments[4] : void 0, l = d, g = {};
        if ("html" == i) g = a.default.html2json(r, e); else if ("md" == i || "markdown" == i) {
            var h = new t.default.Converter().makeHtml(r);
            g = a.default.html2json(h, e), console.log(JSON.stringify(g, " ", " "));
        }
        g.view = {}, g.view.imagePadding = 0, void 0 !== s && (g.view.imagePadding = s);
        var v = {};
        v[e] = g, l.setData(v), l.wxParseImgLoad = o, l.wxParseImgTap = n;
    },
    wxParseTemArray: function(e, t, a, i) {
        for (var r = [], n = i.data, o = null, d = 0; d < a; d++) {
            var s = n[t + d].nodes;
            r.push(s);
        }
        e = e || "wxParseTemArray", (o = JSON.parse('{"' + e + '":""}'))[e] = r, i.setData(o);
    },
    emojisInit: function() {
        var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "", t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "/wxParse/emojis/", i = arguments.length > 2 ? arguments[2] : void 0;
        a.default.emojisInit(e, t, i);
    }
};